package com.jianan.mis.service;

import com.jianan.mis.data.dao.EmployeeDao;
import com.jianan.mis.data.domain.Employee;

import static com.jianan.mis.util.MD5.MD5Encode;

;

public class SecurityServiceImpl implements SecurityService {

	private EmployeeDao employeeDao;

	public boolean login(String username, String password) {
		Employee employee = employeeDao.findUniqueBy(Employee.class,
				"Username", username);
		if (employee != null
				&& MD5Encode(password).equals(employee.getPassword())) {
			return true;
		} else {
			return false;
		}
	}

	public Employee findEmployee(String username) {
		return employeeDao.findUniqueBy(Employee.class, "Username", username);
	}

	public void setEmployeeDao(EmployeeDao employeeDao) {
		this.employeeDao = employeeDao;
	}

}
